package com.example.sso.service.mp.api.controller;

import com.example.rose.common.Result;
import com.example.sso.service.model.dto.MemberLoginDTO;
import com.example.sso.service.model.vo.MemberLoginVO;
import com.example.sso.service.mp.api.service.MemberService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 会员表 前端控制器
 * </p>
 *
 * @author wuyunbin
 * @since 2025-02-22
 */
@Slf4j
@RestController
@RequestMapping("/member")
public class MemberController {
    @Resource
    private MemberService memberService;

    @PostMapping("login")
    public Result<MemberLoginVO> login(@RequestBody MemberLoginDTO memberLoginDTO){
        MemberLoginVO memberLoginVO = memberService.login(memberLoginDTO);
        return Result.success(memberLoginVO);
    }

    @PostMapping("getTokensByRefreshToken/{refreshToken}")
    public Result<MemberLoginVO> getTokensByRefreshToken(@PathVariable String refreshToken){
        MemberLoginVO memberLoginVO = memberService.getTokensByRefreshToken(refreshToken);
        return Result.success(memberLoginVO);
    }
}
